#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <cstring>
#include <climits>
using namespace std;
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

int main() {
    int n, a;
    scanf("%d%d", &n, &a);
    int g = 0;
    int min_b = INT_MAX;
    int max_c = -1;
    for (int i = 0; i < n; i++) {
        int b, c;
        scanf("%d%d", &b, &c);
        min_b = min(min_b, b);
        int b_c = b - c;
        max_c = max(max_c, c);
        if (i == 0) {
            g = b_c;
        }
        else {
            g = gcd(g, b_c);
        }
    }
    int ret = 0;
    //     cout << "max_c == " << max_c << ", g == " << g << endl;
    for (int i = 2; i * i < g; i++) {
        if (g % i == 0 && i > max_c) {
            ret++;
        }
        if (g % (g / i) == 0 && (g / i) > max_c) {
            ret++;
        }
    }
    cout << ret + 1 << endl;


    return 0;
}